package drds.binlog.protocol.protocol_proto;

/**
 * Protobuf type {@code com.alibaba.otter.canal.protocol.Packet}
 */
public final class Packet extends
        com.google.protobuf.GeneratedMessageV3 implements
        // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Packet)
        PacketOrBuilder
{
    public static final int magic_number_field_number = 1;
    public static final int version_field_number = 2;
    public static final int type_field_number = 3;
    public static final int compression_field_number = 4;
    public static final int body_field_number = 5;
    private static final long serialVersionUID = 0L;
    // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Packet)
    private static final Packet DEFAULT_INSTANCE;
    private static final com.google.protobuf.Parser<Packet>
            PARSER = new com.google.protobuf.AbstractParser<Packet>()
    {
        @Override
        public Packet parsePartialFrom(
                com.google.protobuf.CodedInputStream input,
                com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                throws com.google.protobuf.InvalidProtocolBufferException
        {
            return new Packet(input, extensionRegistry);
        }
    };

    static
    {
        DEFAULT_INSTANCE = new Packet();
    }

    private int magicNumberPresentCase_ = 0;

    ;
    private Object magicNumberPresent_;
    private int versionPresentCase_ = 0;
    private Object versionPresent_;
    private int compressionPresentCase_ = 0;

    ;
    private Object compressionPresent_;
    private int type_;
    private com.google.protobuf.ByteString body_;
    private byte memoizedIsInitialized = -1;

    ;

    // Use Packet.newBuilder() to construct.
    private Packet(com.google.protobuf.GeneratedMessageV3.Builder<?> builder)
    {
        super(builder);
    }

    private Packet()
    {
        type_ = 0;
        body_ = com.google.protobuf.ByteString.EMPTY;
    }

    private Packet(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        this();
        if (extensionRegistry == null)
        {
            throw new NullPointerException();
        }
        int mutable_bitField0_ = 0;
        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
                com.google.protobuf.UnknownFieldSet.newBuilder();
        try
        {
            boolean done = false;
            while (!done)
            {
                int tag = input.readTag();
                switch (tag)
                {
                    case 0:
                        done = true;
                        break;
                    case 8:
                    {
                        magicNumberPresentCase_ = 1;
                        magicNumberPresent_ = input.readInt32();
                        break;
                    }
                    case 16:
                    {
                        versionPresentCase_ = 2;
                        versionPresent_ = input.readInt32();
                        break;
                    }
                    case 24:
                    {
                        int rawValue = input.readEnum();

                        type_ = rawValue;
                        break;
                    }
                    case 32:
                    {
                        int rawValue = input.readEnum();
                        compressionPresentCase_ = 4;
                        compressionPresent_ = rawValue;
                        break;
                    }
                    case 42:
                    {

                        body_ = input.readBytes();
                        break;
                    }
                    default:
                    {
                        if (!parseUnknownFieldProto3(
                                input, unknownFields, extensionRegistry, tag))
                        {
                            done = true;
                        }
                        break;
                    }
                }
            }
        } catch (com.google.protobuf.InvalidProtocolBufferException e)
        {
            throw e.setUnfinishedMessage(this);
        } catch (java.io.IOException e)
        {
            throw new com.google.protobuf.InvalidProtocolBufferException(
                    e).setUnfinishedMessage(this);
        } finally
        {
            this.unknownFields = unknownFields.build();
            makeExtensionsImmutable();
        }
    }

    public static final com.google.protobuf.Descriptors.Descriptor
    getDescriptor()
    {
        return BinlogPacket.protocol_Packet_descriptor;
    }

    public static Packet parseFrom(
            java.nio.ByteBuffer data)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return PARSER.parseFrom(data);
    }

    public static Packet parseFrom(
            java.nio.ByteBuffer data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Packet parseFrom(
            com.google.protobuf.ByteString data)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return PARSER.parseFrom(data);
    }

    public static Packet parseFrom(
            com.google.protobuf.ByteString data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Packet parseFrom(byte[] data)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return PARSER.parseFrom(data);
    }

    public static Packet parseFrom(
            byte[] data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException
    {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Packet parseFrom(java.io.InputStream input)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(PARSER, input);
    }

    public static Packet parseFrom(
            java.io.InputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(PARSER, input, extensionRegistry);
    }

    public static Packet parseDelimitedFrom(java.io.InputStream input)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseDelimitedWithIOException(PARSER, input);
    }

    public static Packet parseDelimitedFrom(
            java.io.InputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
    }

    public static Packet parseFrom(
            com.google.protobuf.CodedInputStream input)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(PARSER, input);
    }

    public static Packet parseFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException
    {
        return com.google.protobuf.GeneratedMessageV3
                .parseWithIOException(PARSER, input, extensionRegistry);
    }

    public static Builder newBuilder()
    {
        return DEFAULT_INSTANCE.toBuilder();
    }

    public static Builder newBuilder(Packet prototype)
    {
        return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }

    public static Packet getDefaultInstance()
    {
        return DEFAULT_INSTANCE;
    }

    public static com.google.protobuf.Parser<Packet> parser()
    {
        return PARSER;
    }

    @Override
    public final com.google.protobuf.UnknownFieldSet
    getUnknownFields()
    {
        return this.unknownFields;
    }

    @Override
    protected FieldAccessorTable
    internalGetFieldAccessorTable()
    {
        return BinlogPacket.protocol_Packet_fieldAccessorTable
                .ensureFieldAccessorsInitialized(
                        Packet.class, Builder.class);
    }

    public MagicNumberPresentCase
    getMagicNumberPresentCase()
    {
        return MagicNumberPresentCase.forNumber(
                magicNumberPresentCase_);
    }

    public VersionPresentCase
    getVersionPresentCase()
    {
        return VersionPresentCase.forNumber(
                versionPresentCase_);
    }

    public CompressionPresentCase
    getCompressionPresentCase()
    {
        return CompressionPresentCase.forNumber(
                compressionPresentCase_);
    }

    /**
     * <code>int32 magic_number = 1;</code>
     */
    public int getMagicNumber()
    {
        if (magicNumberPresentCase_ == 1)
        {
            return (Integer) magicNumberPresent_;
        }
        return 0;
    }

    /**
     * <code>int32 version = 2;</code>
     */
    public int getVersion()
    {
        if (versionPresentCase_ == 2)
        {
            return (Integer) versionPresent_;
        }
        return 1;
    }

    /**
     * <code>.com.alibaba.otter.canal.protocol.PacketType type = 3;</code>
     */
    public int getTypeValue()
    {
        return type_;
    }

    /**
     * <code>.com.alibaba.otter.canal.protocol.PacketType type = 3;</code>
     */
    public PacketType getType()
    {
        @SuppressWarnings("deprecation")
        PacketType result = PacketType.valueOf(type_);
        return result == null ? PacketType.unrecognized : result;
    }

    /**
     * <code>.com.alibaba.otter.canal.protocol.Compression compression = 4;</code>
     */
    public int getCompressionValue()
    {
        if (compressionPresentCase_ == 4)
        {
            return (Integer) compressionPresent_;
        }
        return Compression.none_value;
    }

    /**
     * <code>.com.alibaba.otter.canal.protocol.Compression compression = 4;</code>
     */
    public Compression getCompression()
    {
        if (compressionPresentCase_ == 4)
        {
            @SuppressWarnings("deprecation")
            Compression result = Compression.valueOf(
                    (Integer) compressionPresent_);
            return result == null ? Compression.unrecognized : result;
        }
        return Compression.compressioncompatibleproto2;
    }

    /**
     * <code>bytes body = 5;</code>
     */
    public com.google.protobuf.ByteString getBody()
    {
        return body_;
    }

    @Override
    public final boolean isInitialized()
    {
        byte isInitialized = memoizedIsInitialized;
        if (isInitialized == 1) return true;
        if (isInitialized == 0) return false;

        memoizedIsInitialized = 1;
        return true;
    }

    @Override
    public void writeTo(com.google.protobuf.CodedOutputStream output)
            throws java.io.IOException
    {
        if (magicNumberPresentCase_ == 1)
        {
            output.writeInt32(
                    1, (int) ((Integer) magicNumberPresent_));
        }
        if (versionPresentCase_ == 2)
        {
            output.writeInt32(
                    2, (int) ((Integer) versionPresent_));
        }
        if (type_ != PacketType.packagetypecompatibleproto2.getNumber())
        {
            output.writeEnum(3, type_);
        }
        if (compressionPresentCase_ == 4)
        {
            output.writeEnum(4, ((Integer) compressionPresent_));
        }
        if (!body_.isEmpty())
        {
            output.writeBytes(5, body_);
        }
        unknownFields.writeTo(output);
    }

    @Override
    public int getSerializedSize()
    {
        int size = memoizedSize;
        if (size != -1) return size;

        size = 0;
        if (magicNumberPresentCase_ == 1)
        {
            size += com.google.protobuf.CodedOutputStream
                    .computeInt32Size(
                            1, (int) ((Integer) magicNumberPresent_));
        }
        if (versionPresentCase_ == 2)
        {
            size += com.google.protobuf.CodedOutputStream
                    .computeInt32Size(
                            2, (int) ((Integer) versionPresent_));
        }
        if (type_ != PacketType.packagetypecompatibleproto2.getNumber())
        {
            size += com.google.protobuf.CodedOutputStream
                    .computeEnumSize(3, type_);
        }
        if (compressionPresentCase_ == 4)
        {
            size += com.google.protobuf.CodedOutputStream
                    .computeEnumSize(4, ((Integer) compressionPresent_));
        }
        if (!body_.isEmpty())
        {
            size += com.google.protobuf.CodedOutputStream
                    .computeBytesSize(5, body_);
        }
        size += unknownFields.getSerializedSize();
        memoizedSize = size;
        return size;
    }

    @Override
    public boolean equals(final Object obj)
    {
        if (obj == this)
        {
            return true;
        }
        if (!(obj instanceof Packet))
        {
            return super.equals(obj);
        }
        Packet other = (Packet) obj;

        boolean result = true;
        result = result && type_ == other.type_;
        result = result && getBody()
                .equals(other.getBody());
        result = result && getMagicNumberPresentCase().equals(
                other.getMagicNumberPresentCase());
        if (!result) return false;
        switch (magicNumberPresentCase_)
        {
            case 1:
                result = result && (getMagicNumber()
                        == other.getMagicNumber());
                break;
            case 0:
            default:
        }
        result = result && getVersionPresentCase().equals(
                other.getVersionPresentCase());
        if (!result) return false;
        switch (versionPresentCase_)
        {
            case 2:
                result = result && (getVersion()
                        == other.getVersion());
                break;
            case 0:
            default:
        }
        result = result && getCompressionPresentCase().equals(
                other.getCompressionPresentCase());
        if (!result) return false;
        switch (compressionPresentCase_)
        {
            case 4:
                result = result && getCompressionValue()
                        == other.getCompressionValue();
                break;
            case 0:
            default:
        }
        result = result && unknownFields.equals(other.unknownFields);
        return result;
    }

    @Override
    public int hashCode()
    {
        if (memoizedHashCode != 0)
        {
            return memoizedHashCode;
        }
        int hash = 41;
        hash = (19 * hash) + getDescriptor().hashCode();
        hash = (37 * hash) + type_field_number;
        hash = (53 * hash) + type_;
        hash = (37 * hash) + body_field_number;
        hash = (53 * hash) + getBody().hashCode();
        switch (magicNumberPresentCase_)
        {
            case 1:
                hash = (37 * hash) + magic_number_field_number;
                hash = (53 * hash) + getMagicNumber();
                break;
            case 0:
            default:
        }
        switch (versionPresentCase_)
        {
            case 2:
                hash = (37 * hash) + version_field_number;
                hash = (53 * hash) + getVersion();
                break;
            case 0:
            default:
        }
        switch (compressionPresentCase_)
        {
            case 4:
                hash = (37 * hash) + compression_field_number;
                hash = (53 * hash) + getCompressionValue();
                break;
            case 0:
            default:
        }
        hash = (29 * hash) + unknownFields.hashCode();
        memoizedHashCode = hash;
        return hash;
    }

    @Override
    public Builder newBuilderForType()
    {
        return newBuilder();
    }

    @Override
    public Builder toBuilder()
    {
        return this == DEFAULT_INSTANCE
                ? new Builder() : new Builder().mergeFrom(this);
    }

    @Override
    protected Builder newBuilderForType(
            BuilderParent parent)
    {
        Builder builder = new Builder(parent);
        return builder;
    }

    @Override
    public com.google.protobuf.Parser<Packet> getParserForType()
    {
        return PARSER;
    }

    @Override
    public Packet getDefaultInstanceForType()
    {
        return DEFAULT_INSTANCE;
    }

    public enum MagicNumberPresentCase
            implements com.google.protobuf.Internal.EnumLite
    {
        MAGIC_NUMBER(1),
        MAGICNUMBERPRESENT_NOT_SET(0);
        private final int value;

        private MagicNumberPresentCase(int value)
        {
            this.value = value;
        }

        /**
         * @deprecated Use {@link #forNumber(int)} instead.
         */
        @Deprecated
        public static MagicNumberPresentCase valueOf(int value)
        {
            return forNumber(value);
        }

        public static MagicNumberPresentCase forNumber(int value)
        {
            switch (value)
            {
                case 1:
                    return MAGIC_NUMBER;
                case 0:
                    return MAGICNUMBERPRESENT_NOT_SET;
                default:
                    return null;
            }
        }

        public int getNumber()
        {
            return this.value;
        }
    }

    public enum VersionPresentCase
            implements com.google.protobuf.Internal.EnumLite
    {
        VERSION(2),
        VERSIONPRESENT_NOT_SET(0);
        private final int value;

        private VersionPresentCase(int value)
        {
            this.value = value;
        }

        /**
         * @deprecated Use {@link #forNumber(int)} instead.
         */
        @Deprecated
        public static VersionPresentCase valueOf(int value)
        {
            return forNumber(value);
        }

        public static VersionPresentCase forNumber(int value)
        {
            switch (value)
            {
                case 2:
                    return VERSION;
                case 0:
                    return VERSIONPRESENT_NOT_SET;
                default:
                    return null;
            }
        }

        public int getNumber()
        {
            return this.value;
        }
    }

    public enum CompressionPresentCase
            implements com.google.protobuf.Internal.EnumLite
    {
        COMPRESSION(4),
        COMPRESSIONPRESENT_NOT_SET(0);
        private final int value;

        private CompressionPresentCase(int value)
        {
            this.value = value;
        }

        /**
         * @deprecated Use {@link #forNumber(int)} instead.
         */
        @Deprecated
        public static CompressionPresentCase valueOf(int value)
        {
            return forNumber(value);
        }

        public static CompressionPresentCase forNumber(int value)
        {
            switch (value)
            {
                case 4:
                    return COMPRESSION;
                case 0:
                    return COMPRESSIONPRESENT_NOT_SET;
                default:
                    return null;
            }
        }

        public int getNumber()
        {
            return this.value;
        }
    }

    /**
     * Protobuf type {@code com.alibaba.otter.canal.protocol.Packet}
     */
    public static final class Builder extends
            com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
            // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.Packet)
            PacketOrBuilder
    {
        private int magicNumberPresentCase_ = 0;
        private Object magicNumberPresent_;
        private int versionPresentCase_ = 0;
        private Object versionPresent_;
        private int compressionPresentCase_ = 0;
        private Object compressionPresent_;
        private int type_ = 0;
        private com.google.protobuf.ByteString body_ = com.google.protobuf.ByteString.EMPTY;

        // Construct using BinlogPacket.Packet.newBuilder()
        private Builder()
        {
            maybeForceBuilderInitialization();
        }

        private Builder(
                BuilderParent parent)
        {
            super(parent);
            maybeForceBuilderInitialization();
        }

        public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor()
        {
            return BinlogPacket.protocol_Packet_descriptor;
        }

        @Override
        protected FieldAccessorTable
        internalGetFieldAccessorTable()
        {
            return BinlogPacket.protocol_Packet_fieldAccessorTable
                    .ensureFieldAccessorsInitialized(
                            Packet.class, Builder.class);
        }

        private void maybeForceBuilderInitialization()
        {
            if (com.google.protobuf.GeneratedMessageV3
                    .alwaysUseFieldBuilders)
            {
            }
        }

        @Override
        public Builder clear()
        {
            super.clear();
            type_ = 0;

            body_ = com.google.protobuf.ByteString.EMPTY;

            magicNumberPresentCase_ = 0;
            magicNumberPresent_ = null;
            versionPresentCase_ = 0;
            versionPresent_ = null;
            compressionPresentCase_ = 0;
            compressionPresent_ = null;
            return this;
        }

        @Override
        public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType()
        {
            return BinlogPacket.protocol_Packet_descriptor;
        }

        @Override
        public Packet getDefaultInstanceForType()
        {
            return Packet.getDefaultInstance();
        }

        @Override
        public Packet build()
        {
            Packet result = buildPartial();
            if (!result.isInitialized())
            {
                throw newUninitializedMessageException(result);
            }
            return result;
        }

        @Override
        public Packet buildPartial()
        {
            Packet result = new Packet(this);
            if (magicNumberPresentCase_ == 1)
            {
                result.magicNumberPresent_ = magicNumberPresent_;
            }
            if (versionPresentCase_ == 2)
            {
                result.versionPresent_ = versionPresent_;
            }
            result.type_ = type_;
            if (compressionPresentCase_ == 4)
            {
                result.compressionPresent_ = compressionPresent_;
            }
            result.body_ = body_;
            result.magicNumberPresentCase_ = magicNumberPresentCase_;
            result.versionPresentCase_ = versionPresentCase_;
            result.compressionPresentCase_ = compressionPresentCase_;
            onBuilt();
            return result;
        }

        @Override
        public Builder clone()
        {
            return (Builder) super.clone();
        }

        @Override
        public Builder setField(
                com.google.protobuf.Descriptors.FieldDescriptor field,
                Object value)
        {
            return (Builder) super.setField(field, value);
        }

        @Override
        public Builder clearField(
                com.google.protobuf.Descriptors.FieldDescriptor field)
        {
            return (Builder) super.clearField(field);
        }

        @Override
        public Builder clearOneof(
                com.google.protobuf.Descriptors.OneofDescriptor oneof)
        {
            return (Builder) super.clearOneof(oneof);
        }

        @Override
        public Builder setRepeatedField(
                com.google.protobuf.Descriptors.FieldDescriptor field,
                int index, Object value)
        {
            return (Builder) super.setRepeatedField(field, index, value);
        }

        @Override
        public Builder addRepeatedField(
                com.google.protobuf.Descriptors.FieldDescriptor field,
                Object value)
        {
            return (Builder) super.addRepeatedField(field, value);
        }

        @Override
        public Builder mergeFrom(com.google.protobuf.Message other)
        {
            if (other instanceof Packet)
            {
                return mergeFrom((Packet) other);
            } else
            {
                super.mergeFrom(other);
                return this;
            }
        }

        public Builder mergeFrom(Packet other)
        {
            if (other == Packet.getDefaultInstance()) return this;
            if (other.type_ != 0)
            {
                setTypeValue(other.getTypeValue());
            }
            if (other.getBody() != com.google.protobuf.ByteString.EMPTY)
            {
                setBody(other.getBody());
            }
            switch (other.getMagicNumberPresentCase())
            {
                case MAGIC_NUMBER:
                {
                    setMagicNumber(other.getMagicNumber());
                    break;
                }
                case MAGICNUMBERPRESENT_NOT_SET:
                {
                    break;
                }
            }
            switch (other.getVersionPresentCase())
            {
                case VERSION:
                {
                    setVersion(other.getVersion());
                    break;
                }
                case VERSIONPRESENT_NOT_SET:
                {
                    break;
                }
            }
            switch (other.getCompressionPresentCase())
            {
                case COMPRESSION:
                {
                    setCompressionValue(other.getCompressionValue());
                    break;
                }
                case COMPRESSIONPRESENT_NOT_SET:
                {
                    break;
                }
            }
            this.mergeUnknownFields(other.unknownFields);
            onChanged();
            return this;
        }

        @Override
        public final boolean isInitialized()
        {
            return true;
        }

        @Override
        public Builder mergeFrom(
                com.google.protobuf.CodedInputStream input,
                com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                throws java.io.IOException
        {
            Packet parsedMessage = null;
            try
            {
                parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
            } catch (com.google.protobuf.InvalidProtocolBufferException e)
            {
                parsedMessage = (Packet) e.getUnfinishedMessage();
                throw e.unwrapIOException();
            } finally
            {
                if (parsedMessage != null)
                {
                    mergeFrom(parsedMessage);
                }
            }
            return this;
        }

        public MagicNumberPresentCase
        getMagicNumberPresentCase()
        {
            return MagicNumberPresentCase.forNumber(
                    magicNumberPresentCase_);
        }

        public Builder clearMagicNumberPresent()
        {
            magicNumberPresentCase_ = 0;
            magicNumberPresent_ = null;
            onChanged();
            return this;
        }

        public VersionPresentCase
        getVersionPresentCase()
        {
            return VersionPresentCase.forNumber(
                    versionPresentCase_);
        }

        public Builder clearVersionPresent()
        {
            versionPresentCase_ = 0;
            versionPresent_ = null;
            onChanged();
            return this;
        }

        public CompressionPresentCase
        getCompressionPresentCase()
        {
            return CompressionPresentCase.forNumber(
                    compressionPresentCase_);
        }

        public Builder clearCompressionPresent()
        {
            compressionPresentCase_ = 0;
            compressionPresent_ = null;
            onChanged();
            return this;
        }

        /**
         * <code>int32 magic_number = 1;</code>
         */
        public int getMagicNumber()
        {
            if (magicNumberPresentCase_ == 1)
            {
                return (Integer) magicNumberPresent_;
            }
            return 17;
        }

        /**
         * <code>int32 magic_number = 1;</code>
         */
        public Builder setMagicNumber(int value)
        {
            magicNumberPresentCase_ = 1;
            magicNumberPresent_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>int32 magic_number = 1;</code>
         */
        public Builder clearMagicNumber()
        {
            if (magicNumberPresentCase_ == 1)
            {
                magicNumberPresentCase_ = 0;
                magicNumberPresent_ = null;
                onChanged();
            }
            return this;
        }

        /**
         * <code>int32 version = 2;</code>
         */
        public int getVersion()
        {
            if (versionPresentCase_ == 2)
            {
                return (Integer) versionPresent_;
            }
            return 0;
        }

        /**
         * <code>int32 version = 2;</code>
         */
        public Builder setVersion(int value)
        {
            versionPresentCase_ = 2;
            versionPresent_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>int32 version = 2;</code>
         */
        public Builder clearVersion()
        {
            if (versionPresentCase_ == 2)
            {
                versionPresentCase_ = 0;
                versionPresent_ = null;
                onChanged();
            }
            return this;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.PacketType type = 3;</code>
         */
        public int getTypeValue()
        {
            return type_;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.PacketType type = 3;</code>
         */
        public Builder setTypeValue(int value)
        {
            type_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.PacketType type = 3;</code>
         */
        public PacketType getType()
        {
            @SuppressWarnings("deprecation")
            PacketType result = PacketType.valueOf(type_);
            return result == null ? PacketType.unrecognized : result;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.PacketType type = 3;</code>
         */
        public Builder setType(PacketType value)
        {
            if (value == null)
            {
                throw new NullPointerException();
            }

            type_ = value.getNumber();
            onChanged();
            return this;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.PacketType type = 3;</code>
         */
        public Builder clearType()
        {

            type_ = 0;
            onChanged();
            return this;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.Compression compression = 4;</code>
         */
        public int getCompressionValue()
        {
            if (compressionPresentCase_ == 4)
            {
                return ((Integer) compressionPresent_).intValue();
            }
            return 0;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.Compression compression = 4;</code>
         */
        public Builder setCompressionValue(int value)
        {
            compressionPresentCase_ = 4;
            compressionPresent_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.Compression compression = 4;</code>
         */
        public Compression getCompression()
        {
            if (compressionPresentCase_ == 4)
            {
                @SuppressWarnings("deprecation")
                Compression result = Compression.valueOf(
                        (Integer) compressionPresent_);
                return result == null ? Compression.unrecognized : result;
            }
            return Compression.compressioncompatibleproto2;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.Compression compression = 4;</code>
         */
        public Builder setCompression(Compression value)
        {
            if (value == null)
            {
                throw new NullPointerException();
            }
            compressionPresentCase_ = 4;
            compressionPresent_ = value.getNumber();
            onChanged();
            return this;
        }

        /**
         * <code>.com.alibaba.otter.canal.protocol.Compression compression = 4;</code>
         */
        public Builder clearCompression()
        {
            if (compressionPresentCase_ == 4)
            {
                compressionPresentCase_ = 0;
                compressionPresent_ = null;
                onChanged();
            }
            return this;
        }

        /**
         * <code>bytes body = 5;</code>
         */
        public com.google.protobuf.ByteString getBody()
        {
            return body_;
        }

        /**
         * <code>bytes body = 5;</code>
         */
        public Builder setBody(com.google.protobuf.ByteString value)
        {
            if (value == null)
            {
                throw new NullPointerException();
            }

            body_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>bytes body = 5;</code>
         */
        public Builder clearBody()
        {

            body_ = getDefaultInstance().getBody();
            onChanged();
            return this;
        }

        @Override
        public final Builder setUnknownFields(
                final com.google.protobuf.UnknownFieldSet unknownFields)
        {
            return super.setUnknownFieldsProto3(unknownFields);
        }

        @Override
        public final Builder mergeUnknownFields(
                final com.google.protobuf.UnknownFieldSet unknownFields)
        {
            return super.mergeUnknownFields(unknownFields);
        }


        // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Packet)
    }

}
